<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增电影基本信息')" />
    <th:block th:include="include :: header('文件上传')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-ticketmoviebaseinfo-add">
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">是否删除，1为是，0为否：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="del" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">电影名：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">导演：</label>
                <div class="col-sm-8">
                    <input name="director" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">主演：</label>
                <div class="col-sm-8">
                    <input name="actor" class="form-control" type="text">
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">电影上映年份：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="movieYear" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->

            <div class="form-group">
                <label class="col-sm-3 control-label">电影上映年份：</label>
                <div class="col-sm-8">
                <select class="form-control" name="movieYear"></select>
                </div>
            </div>


            <div class="form-group">    
                <label class="col-sm-3 control-label">电影上映区域：</label>
                <div class="col-sm-8">
<!--                    <input name="movieArea" class="form-control" type="text">-->
                    <select class="form-control" name="movieArea"></select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">电影语言：</label>
                <div class="col-sm-8">
<!--                    <input name="language" class="form-control" type="text">-->
                    <select class="form-control" name="language"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">电影简介：</label>
                <div class="col-sm-8">
                    <textarea name="introduction" class="form-control"></textarea>
                </div>
            </div>
<!--            电影图片存路径-->
<!--            <div class="form-group" style="display: none;">-->
<!--&lt;!&ndash;                <label class="col-sm-3 control-label">电影图片：</label>&ndash;&gt;-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="image" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">票价：</label>
                <div class="col-sm-8">
                    <input name="price" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态(0即将上映，1上映中，2已下架）：</label>
                <div class="col-sm-8">
                    <input name="state" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="font-noraml">电影封面</label>
                <input name="image" style="width: 100%;"/>
                <div class="file-loading" style="width: 50px;">
                    <input id="singleFile" name="file" type="file" >
                </div>
            </div>


            <!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">操作者用户id：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="operateId" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">操作者用户名：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="operateName" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/ticketmoviebaseinfo"
        $("#form-ticketmoviebaseinfo-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {

                var data = $('#form-ticketmoviebaseinfo-add').serialize();
                console.log("准备提交数据="+JSON.stringify(data));
               $.operate.save(prefix + "/add", data);
            }
        }


        //上传单文件附件
        $(document).ready(function () {
            // 单图上传
            $("#singleFile").fileinput({
                uploadUrl: ctx + 'common/upload',
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                var rsp = data.response;
                log.info("return url：" + rsp.url)
                log.info("reutrn fileName：" + rsp.fileName);

                $("input[name=image]").val(rsp.fileName);

            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('');
                $("input[name=image]").val("");
            })


            //页面初始化，初始化年份option
            $.get(ctx + 'system/ticketmovieyear/getYreaList', null, function(data){//param为参数---键值对方式
                $.each(data.array, function(i,item){
                    $("select[name=movieYear]").append("<option value='"+item+"'>"+item+"</option>");
                });
            });
            //电影区域类型
            $.get(ctx + 'system/ticketmovieareatype/getAreaTypeList', null, function(data){//param为参数---键值对方式
                $.each(data.array, function(i,item){
                    $("select[name=movieArea]").append("<option value='"+item+"'>"+item+"</option>");
                });
            });
            //电影类型
            $.get(ctx + 'system/ticketmovietype/getMovieTypeList', null, function(data){//param为参数---键值对方式
                $.each(data.array, function(i,item){
                    $("select[name=language]").append("<option value='"+item+"'>"+item+"</option>");
                });
            });
        });


    </script>
</body>
</html>